function connectWebViewJavascriptBridge(callback) {
  // 根据userAgent获取浏览器属性
  var browers = window.browers = {};
  var ua = navigator.userAgent.toLowerCase();
  var version;


  browers.Android = ua.match(/android/);
  browers.iOS = ua.match(/ipad|iphone|ios/);
  browers.appUA = ua.match(/NewsApp\/([\d.]+)/i);
  if (browers.appUA && browers.appUA.length && browers.appUA.length > 1) {
    var v = browers.appUA[1].replace(/\./ig, '');
    version = parseInt(v);
    browers.version = version;
  }
  var globalParams = {
    Authorization: ''
  }






  if (browers.version >= 729 && browers.iOS) {
    if (window.WebViewJavascriptBridge) {
      return callback(WebViewJavascriptBridge);
    }
    if (window.WVJBCallbacks) {
      return window.WVJBCallbacks.push(callback);
    }
    window.WVJBCallbacks = [callback];
    var WVJBIframe = document.createElement('iframe');
    WVJBIframe.style.display = 'none';
    WVJBIframe.src = 'https://__bridge_loaded__';
    document.documentElement.appendChild(WVJBIframe);
    setTimeout(function () {
      document.documentElement.removeChild(WVJBIframe)
    }, 0)
  } else {
    if (window.WebViewJavascriptBridge) {
      if (!WebViewJavascriptBridge._messageHandler) {
        WebViewJavascriptBridge.init(function (message, responseCallback) {});
      }
      callback(WebViewJavascriptBridge);
    } else {
      document.addEventListener('WebViewJavascriptBridgeReady', function () {
        if (!WebViewJavascriptBridge._messageHandler) {
          WebViewJavascriptBridge.init(function (message, responseCallback) {});
        }
        callback(WebViewJavascriptBridge);
      }, false);
    }
  }
}

export function isAppUa(){
    return navigator.userAgent.toLowerCase().match(/NewsApp\/([\d.]+)/i)
}
export function DQDOpenSDK_share(isImmediately) {
  var url = '';
  connectWebViewJavascriptBridge((bridge) => {
    bridge.callHandler('shareUrl', {
      'is_immediately': isImmediately, //是否立即唤起分享
      'is_showBtn': 'true', // 右上角分享按钮展示
      'is_picture': false, // true时分享为图片，false分享为链接
      'title': '来自星际的挑战信，这场球赛你会参加吗？',
      'content': '我们的星球遭遇了大危机，关键时刻需要一场足球赛来决定，热爱足球的你，敢接受这个挑战吗？',
      'url': url
    });
  });
}
// DQDOpenSDK_share(true);